package com.meixiang.activity.account.manager;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import com.meixiang.R;
import com.meixiang.main.BaseActivity;
import com.meixiang.main.MXApplication;
import com.meixiang.view.OldPaymentKeyDialog;
import com.meixiang.view.PaymentKeyDialog;
import com.meixiang.view.TitleView;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 *  对于所有支付密码
 *
 * @author 验证原支付密码
 */
public class PayPassWordActivity extends BaseActivity implements PaymentKeyDialog.InputFinishListener {

    @Bind(R.id.title)
    TitleView title;
    @Bind(R.id.password)
    OldPaymentKeyDialog password;
    private String ClassStatus;
    private Activity mActivity;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_pay_off_set_new_password);
        mActivity=PayPassWordActivity.this;
        ButterKnife.bind(this);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initTitle() {
        title.setTitle(R.string.change_pay_off_password);
        title.setLeftImageButton(R.mipmap.back);
        title.showLeftButton(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void initView() {
        ClassStatus = getIntent().getExtras().getString("ClassStatus");
        if(ClassStatus.equals("a")){
            password.setKeyTitle(R.string.verify_old_pay_off_password);

        }
//        password.setInputFinishListener(new OldPaymentKeyDialog.InputFinishListener() {
//            @Override
//            public void onInputFinish(String pwd) {
//                Map<String,String> vals=new HashMap<String, String>();
//                vals.put("OldPwd",pwd);
//                MXApplication.mApp.getSession().set(vals);
//            }
//        });

         password.juumActivity(PayPassWordActivity.class,ClassStatus);
    }

    @Override
    protected void setData() {
        MXApplication.mApp.AddActivity(mActivity);
    }

    @Override
    public void onClick(View v) {

    }


    @Override
    public void onInputFinish(String pwd) {
        if(pwd.toString().length()==6){
            ClassStatus="b";
            if(ClassStatus.equals("b")){
                password.setKeyTitle(R.string.pay_off_set_new_password);

            }if(ClassStatus.equals("c")){
                password.setKeyTitle(R.string.repeatpay_new_password_pay_off);
            }
            getChangePassword();//修改支付密码接口
        }

        password.juumActivity(PayPassWordActivity.class,ClassStatus);//UPDATPAYMENTPASSWORD_URL
    }
    private  void getChangePassword(){

//        HttpParams params = new HttpParams();
//
////        newPassword	String	必填			新的支付密码
////        oldPassword	String	必填			旧的支付密码
//        params.put("oldPassword", DesUtil.md5(""));
//        params.put("newPassword", DesUtil.md5(""));
//        OkHttpUtils.post(Config.UPDATPAYMENTPASSWORD_URL).tag(this).params(params).execute(new HttpCallBack(this,"正在修改密码...") {
//            @Override
//            public void onSucceed(JSONObject result, String code, String message) {
//                if (code.equals("0")){
//                    finish();
//                    AbToastUtil.showToast(PayPassWordActivity.this, message);
//                }else {
//
//                    AbToastUtil.showToast(PayPassWordActivity.this, message);
//                }
//            }
//
//            @Override
//            public void onError(String code, String message) {
//
//                AbToastUtil.showToast(PayPassWordActivity.this, message);
//            }
//        });




    }




}
